//
//  UIButton+Extension.swift
//  SinaWeibo
//
//  Created by mac on 16/3/4.
//  Copyright © 2016年 itheima. All rights reserved.
//

import UIKit

extension UIButton{

    //给UIButton 扩展一个构造函数
    //1.背景图片+图片
    convenience init(backgroundImageName:String,imageName:String){
    
        self.init()
        
        setBackgroundImage(UIImage(named: backgroundImageName), forState: .Normal)
        setImage(UIImage(named: imageName), forState: .Normal)
        
        //设置高亮
        setBackgroundImage(UIImage(named: backgroundImageName + "_highlighted"), forState: .Highlighted)
        setImage(UIImage(named: imageName + "_highlighted"), forState: .Highlighted)
    }
    
    
    //2.背景图片+文案
    convenience init(backgroundImageName:String,title:String,titleColor:UIColor){
    
        self.init()
        
        setBackgroundImage(UIImage(named: backgroundImageName), forState: .Normal)
        setTitle(title, forState: .Normal)
        setTitleColor(titleColor, forState: .Normal)
    }
}
